﻿using DG.Tweening;
using TMPro;
using UnityEngine;

public static class ExpandClass
{
    /// <summary>
    /// 检查当前动画的标签是否为传参中的标签
    /// </summary>
    /// <param name="animator"></param>
    /// <param name="tag"></param>
    /// <param name="layer"></param>
    /// <returns></returns>
    public static bool AnimationAtTag(this Animator animator, string tag, int layer = 0)
    {
        return animator.GetCurrentAnimatorStateInfo(layer).IsTag(tag);
    }
    public static Tweener DOAlpha(this TMP_Text text, float endValue, float duration)
    {
        return DOTween.To(
            () => text.color.a,
            alpha => {
                Color newColor = text.color;
                newColor.a = alpha;
                text.color = newColor;
            },
            endValue,
            duration
        );
    }

}